import json

# 从TXT文件中读取多个订单簿数据
order_books = []

with open('./order_book/08_23_02_BTCUSDT.txt', 'r') as file:
    for line in file:
        depth_loaded = json.loads(line.strip())  # 将每一行的JSON字符串解析为Python字典
        order_books.append(depth_loaded)

# 输出读取的订单簿数据
for i, order_book in enumerate(order_books, start=1):
    print(f"\n订单簿 {i}:")
    print(f"买单: {order_book['bids'][:5]}")  # 示例输出前5个买单
    print(f"卖单: {order_book['asks'][:5]}")  # 示例输出前5个卖单